// components/the-navbar/index.js
import { virtualHostConfig } from '@/behavior/virtualHost'
import { commonBehavior } from '@/behavior/common'

Component({
  ...virtualHostConfig({
    config: {
      options: {
        multipleSlots: true // 在组件定义时的选项中启用多slot支持
      }
    },
    behaviors: [commonBehavior]
  }),

  /**
   * 组件的属性列表
   */
  properties: {
    animation: {
      type: Boolean,
      value: true
    },
    delta: {
      type: Number,
      value: 1
    },
    fixed: {
      type: Boolean,
      value: true
    },
    leftArrow: Boolean,
    leftArrowIcon: {
      type: String,
      value: 'chevron-left'
    },
    placeholder: {
      type: Boolean,
      value: true
    },
    title: String,
    titleMaxLength: Number,
    visible: {
      type: Boolean,
      value: true
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  lifetimes: {
    attached () {
      if (getCurrentPages().length === 1) {
        this.setData({
          leftArrowIcon: '/images/home.svg'
        })
      }
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onBackFail () {
      wx.switchTab({
        url: '/pages/index/index'
      })
    }
  }
})